package logic;

import java.awt.Point;
import java.awt.Rectangle;
import java.io.Serializable;
import java.util.Vector;

import main.GameDef;

public class Player implements GameDef, Serializable{
	private static final long serialVersionUID = 519539197281722445L;
	/*
 * Atributes
 */
	public String name;
	public int gold;
	public int id;
	public Rectangle castlePosition;
	public Vector <Piece>castle;
	public int firedAttacks;
	public int status;
	final static int ACTIVE = 1;
	final static int INACTIVE = 0;

/*
 * Constructors
 */	
	public Player(String _name, int _id){
		name = _name;
		gold = 100;
		id = _id;
		castle = new Vector <Piece>(0);
		status = ACTIVE;
	}
	
/*
 * Setters
 */
	public boolean setCastlePosition(Point position){
		Rectangle rect = new Rectangle(position.x, position.y, CASTLE_WIDTH, CASTLE_HEIGHT);
		castlePosition = rect;
		return true;
	}
	
	public int cantPieces(int pieceType){
		int cant = 0;
		
		for(int i = 0; i < castle.size(); i++){
			if(castle.get(i).type == pieceType && castle.get(i).status == Piece.ACTIVE){
				cant++;
			}
		}
		
		return cant;
	}
	
	public int cantPieces(){
		int cant = 0;
		
		for(int i = 0; i < castle.size(); i++){
			if(castle.get(i).status == Piece.ACTIVE){
				cant++;
			}
		}
		
		return cant;
	}
}
